﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PL.Formularios
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {

        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Archivos de texto (*.txt)|*.txt|Todos los archivos (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Archivos de texto (*.txt)|*.txt|Todos los archivos (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void printPreviewToolStripButton_Click(object sender, EventArgs e)
        {
            //Form childForm = new Form1();
            //childForm.MdiParent = this;
            //childForm.Text = "Ventana " + childForm.Text;
            //childForm.Show();
        }

        private void ventasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmVenta();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void lotesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmLotes();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void productosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmProductos();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void clientesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmClientes();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void bodegasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form childForm = new frmBodegas();
            //childForm.MdiParent = this;
            //childForm.Text = "Ventana " + childForm.Text;
            //childForm.Show();
        }

        private void cosechasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form childForm = new frmCosechas();
            //childForm.MdiParent = this;
            //childForm.Text = "Ventana " + childForm.Text;
            //childForm.Show();
        }

        private void productoresToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmProductores();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void unidadesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form childForm = new frmUnidades();
            //childForm.MdiParent = this;
            //childForm.Text = "Ventana " + childForm.Text;
            //childForm.Show();
        }

        void MuestrafrmReporte(int num)
        {
            Form childForm = new frmReportes(num);
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }       

        private void statusToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form childForm = new frmStatus();
            //childForm.MdiParent = this;
            //childForm.Text = "Ventana " + childForm.Text;
            //childForm.Show();
        }

        private void embarquesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new frmEmbarque();
            childForm.MdiParent = this;
            childForm.Text = "Ventana " + childForm.Text;
            childForm.Show();
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dlgresult = MessageBox.Show("Desea salir del sistema?",
                     "AgriComer",
                     MessageBoxButtons.YesNo,
                     MessageBoxIcon.Information);
            if (dlgresult == DialogResult.No)
                e.Cancel = true;
        }

        private void resumenGeneralToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(1);
        }

        private void resumenGeneralToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(2);
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            MdiClient ctlMDI;
            foreach (Control ctl in this.Controls)
            {
                try
                {
                    ctlMDI = (MdiClient)ctl;
                    ctlMDI.BackColor = this.BackColor;
                }
                catch (InvalidCastException) { }
            }

        }

        private void pagadoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(4);
        }

        private void sinPreLiquidarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(5);
        }

        private void preliquidadoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(6);
        }

        private void sociedadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(7);
        }

        private void semillaToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MuestrafrmReporte(8);
        }
    }
}
